﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.BaseInfoDetailServiceRef;

    public class BaseInfoDetailServiceClientProxy : BasePage
    {
        public string DeleteDetail(List<string> mainID, List<string> subID, List<string> pk3, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.DeleteDetail(mainID, subID, pk3, className, pubParasInfo);
            }
        }

        public DataSet GetAllDetailInfo(string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.GetAllDetailInfo(className, pubParasInfo);
            }
        }

        public DataSet GetDetaiInfolByQueryEntity(object obj, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.GetDetaiInfolByQueryEntity(obj, className, pubParasInfo);
            }
        }

        public object GetDetailInfoByID(string id, string subID, string pk3, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.GetDetailInfoByID(id, subID, pk3, className, pubParasInfo);
            }
        }

        public List<object> GetDetailInfoListByID(string mainID, string subID, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.GetDetailInfoListByID(mainID, subID, className, pubParasInfo);
            }
        }

        public static BaseInfoDetailServiceClientProxy GetInstance()
        {
            return new BaseInfoDetailServiceClientProxy();
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertDetail(object obj, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.InsertDetail(obj, className, pubParasInfo);
            }
        }

        public string UpdateDetail(object obj, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.UpdateDetail(obj, className, pubParasInfo);
            }
        }

        public string UpdateIsActive(List<string> mainID, List<string> subID, string isActive, string className)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BaseInfoDetailServiceClient client = new BaseInfoDetailServiceClient("WSHttpBinding_IBaseInfoDetailService"))
            {
                return client.UpdateIsActive(mainID, subID, isActive, className, pubParasInfo);
            }
        }
    }
}

